package com.iss.apartmentmanage.utils;

import java.util.*;

/**
 *
 */
public class Create30DayMapUtil {

    public static List<Map<String, String>> createMap(int createDays) {
        Date nowDate = new Date();
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(nowDate);
        calendar.add(Calendar.DAY_OF_YEAR, -createDays + 1);
        System.out.println(calendar);
        List<Map<String, String>> mapList = new ArrayList<>();
        for (int i = 0; i < createDays; i++) {
            Map<String, String> map = new HashMap<>();
            map.put("checkinData", "0");
            map.put("time", DateFormat.formatDateToGeneralType(calendar.getTime(), "yyyy-MM-dd"));
            mapList.add(map);
            // 前一天
            calendar.add(Calendar.DAY_OF_YEAR, +1);
        }
        return mapList;
    }

    public static void main(String[] args) {
        List<Map<String, String>> mapList = createMap(30);
  //      for (Map m : mapList) {
//        Map<String,String> map=m;
//        for(Map.Entry<String,String> m2: map.entrySet()){
//            m2.getValue();
//            m2.getKey();
//            System.out.println(m2);
//        }
//            map.foreach((key,value)->{sout(key+”:”+value)})


 //       }
        mapList.forEach(item->{
            System.out.println(item);
        });
    }

}
